import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from "path"
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'


export default defineConfig({
  plugins: [vue(),
  AutoImport({
    resolvers: [ElementPlusResolver()],
  }),
  Components({
    resolvers: [ElementPlusResolver()],
  }),],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src")
    }
  },
  server: {
    proxy: {
      "/api": {
        target: "http://kumanxuan1.f3322.net:8881/cms",
        changeOrigin: true,
        // 如果没写这个rewrite  在请求的时候，会向服务器发送的请求的地址，会带上
        // 在axios封装里面的baseurl
        // 原本后端要的是https://sc.wolfcode.cn/aip/login
        // 所以在代理服务器里面，需要把url重写（rewrite）
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    }
  }
})
